package com.evamay.kotlindemo.ui.rxdemo

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.evamay.kotlindemo.R
import io.reactivex.Observable
import io.reactivex.Observer
import io.reactivex.android.schedulers.AndroidSchedulers
import org.reactivestreams.Subscriber
import java.nio.channels.AcceptPendingException
import java.util.*
import java.util.function.Consumer

class RxDemoActivity :AppCompatActivity() {
    var type=0
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_rx_demo)
        initData()
    }

    private fun initData() {
        type=intent.getIntExtra("type",0)
        when(type){
            1->{
                defaultRxAndroid()
            }
        }
    }

    private fun defaultRxAndroid() {


        var consumer= Consumer<String> {

        }
        var observer=Observer(){ observable: java.util.Observable, any: Any ->

        }

        Observable.just("hello")
                .observeOn(AndroidSchedulers.mainThread())//切换线程
                .subscribe()
    }
}


